import { PrismaClient } from '@prisma/client';
import express from 'express';
import AdminRouter from './admin/index.js';
import FlightRouter from './flight/index.js';
import PetRouter from './pet/index.js';
import cors from 'cors'




const app = express();
app.use(cors())
app.use(express.json())
app.use(express.urlencoded({ extended: true }))
app.use(express.static('./public'))

const db = new PrismaClient();
app.use((req, res, next) => {
    req.db = db
    res.fail = (info, data) => {
        res.send({ success: false, info, data })
    }
    res.ok = (info, data) => {
        res.send({ success: true, info, data })
    }

    next()
})

//导出的接口，要import
AdminRouter(app);
FlightRouter(app)
PetRouter(app)



app.listen(3300, () => { console.log('server is running') })